use switch::sip2::register::SipRegEvent;
use tracing::trace;

use crate::db::phone_nodedtl_is_sip_num;

///根据给定用户名,返回相对应的密码.用于用户的sip注册
pub async fn user_login_sip_passwd_logic(name: &str) -> Option<String> {
	trace!("向数据库请求用户号码是否存在:{}",name);
	if phone_nodedtl_is_sip_num(name).await {
		Some(name.to_owned())
	} else {
		None
	}
}

pub fn business_reg(event: SipRegEvent) {
	match event {
		SipRegEvent::RegistSuccess(ev) => tracing::info!("成功注册...{ev:?}"),
		SipRegEvent::RegistLoginOut(ev) => tracing::info!("登出操作...{ev:?}"),
		SipRegEvent::RegistFailure(ev) => tracing::info!("注册失败...{ev:?}"),
	}
}